WORK_DIR=~/OpenHarmony
TEST_CASE=$1
TEST_CASE_BASENAME=${TEST_CASE%.*}

FRONT_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_frontend

# release
# SET_ENV_CMD="export LD_LIBRARY_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_runtime/:$WORK_DIR/prebuilts/clang/ohos/linux-x86_64/llvm/lib:$WORK_DIR/out/rk3568/clang_x64/thirdparty/zlib/:$WORK_DIR/out/rk3568/clang_x64/thirdparty/icu/"
# RUNTIME_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_runtime

# debug
SET_COMPILER_ENV_CMD="export LD_LIBRARY_PATH=$WORK_DIR/out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime/:$WORK_DIR/prebuilts/clang/ohos/linux-x86_64/llvm/lib:$WORK_DIR/out/rk3568/clang_x64/thirdparty/zlib/:$WORK_DIR/out/rk3568/clang_x64/thirdparty/icu/"
X86_RUNTIME_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime
AARCH64_RUNTIME_TOOL_PATH=$WORK_DIR/out/rk3568/exe.unstripped/arkcompiler/ets_runtime


GEN_ABC_CMD="$FRONT_TOOL_PATH/es2abc --merge-abc --output $TEST_CASE_BASENAME.abc $TEST_CASE"
AOT_CMD="$X86_RUNTIME_TOOL_PATH/ark_aot_compiler --compiler-target-triple=aarch64-unknown-linux-gnu --aot-file=$TEST_CASE_BASENAME --enable-litecg=true  $TEST_CASE_BASENAME.abc"

SET_VM_ENV_CMD="export LD_LIBRARY_PATH=$WORK_DIR/prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos:$WORK_DIR/out/rk3568/lib.unstripped/arkcompiler/ets_runtime:$WORK_DIR/out/rk3568/lib.unstripped/thirdparty/bounds_checking_function:$WORK_DIR/out/rk3568/lib.unstripped/thirdparty/icu:$WORK_DIR/out/rk3568/lib.unstripped/thirdparty/zlib:$WORK_DIR/out/rk3568/lib.unstripped/resourceschedule/frame_aware_sched:$WORK_DIR/out/rk3568/lib.unstripped/hiviewdfx/hilog:$WORK_DIR/out/rk3568/lib.unstripped/startup/init"
RUN_VM_CMD="qemu-aarch64 $AARCH64_RUNTIME_TOOL_PATH/ark_js_vm --icu-data-path=$WORK_DIR/third_party/icu/ohos_icu4j/data/ --aot-file=$TEST_CASE_BASENAME --entry-point=$TEST_CASE_BASENAME $TEST_CASE_BASENAME.abc"

echo
echo $GEN_ABC_CMD
echo
$GEN_ABC_CMD

echo $SET_COMPILER_ENV_CMD
echo
$SET_COMPILER_ENV_CMD

echo $AOT_CMD
echo
$AOT_CMD >aot_log.txt

echo $SET_VM_ENV_CMD
echo
$SET_VM_ENV_CMD

echo $RUN_VM_CMD
echo
$RUN_VM_CMD
